﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace OrderManagementForm
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

       
        //修改订单页面
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("请输入订单号！");
            }
            else 
            {
                int id3 = Convert.ToInt32(textBox1.Text);  
                foreach( OrderManagement.order cc in OrderManagement.Order) {
                    if (cc.id == id3) {
                        //先删除该订单
                        OrderManagement.Order.Remove(cc);
                        //获取各个输入文本框里面的内容
                        int id = Convert.ToInt32(textBox1.Text);
                        string customer = textBox2.Text;
                        string goods = textBox3.Text;
                        double money = Convert.ToDouble(textBox4.Text);
                        double price = Convert.ToDouble(textBox5.Text);
                        double amount = Convert.ToDouble(textBox6.Text);

                        //添加订单
                        OrderManagement.order aaa = new OrderManagement.order(id, customer, goods, money);
                        OrderManagement.Order.Add(aaa);
                        //添加订单详细
                        OrderManagement.orderitem bbb = new OrderManagement.orderitem(id, customer, goods, money, price, amount);
                        OrderManagement.OrderItem.Add(bbb);
                        MessageBox.Show("你修改的的订单内容为：\n 订单号：" + bbb.id + " 客户：" +
                           bbb.customer + " 商品名称：" + bbb.goods + " 单价：" + bbb.price + " 数目：" + bbb.amount
                           + "  金额：" + bbb.price * bbb.amount);
                        Form1 f1 = new Form1();
                        this.Hide();
                        f1.ShowDialog();
                        this.Dispose();

                    }
                    else
                    {
                        MessageBox.Show("不存在你要修改的订单！");
                    }
                }
                   
            }
        }

     
    }
}
